<template>
  <el-button @click="btnClick" :loading="loading" :disabled="buttonText!=='获取验证码'&&'disabled'">
    {{buttonText}}
  </el-button>
</template>

<script>
export default {
  props: {
    phoneNumber: null
  },
  data() {
    return {
      buttonText: '获取验证码',
      loading: false
    }
  },
  methods: {
    btnClick(e) {
      this.$emit('click', e)
    },
    send() {
      let countDown = 60;

      function fn() {
        --countDown
        if (countDown === 0) {
          clearInterval(interval)
          this.buttonText = '获取验证码'
        } else {
          this.buttonText = countDown + '秒后重新获取'
        }
      }

      fn.call(this)
      let interval = setInterval(() => {
        fn.call(this)
      }, 1000)
    }
  }
}
</script>

<style scoped>

</style>
